<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>mro - Method Resolution Order - Perldoc Browser</title>
    <link rel="search" href="https://perldoc.perl.org/opensearch.xml" type="application/opensearchdescription+xml" title="Perldoc Browser">
    <link rel="canonical" href="https://perldoc.perl.org/mro">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.5.0/styles/stackoverflow-light.min.css" integrity="sha512-cG1IdFxqipi3gqLmksLtuk13C+hBa57a6zpWxMeoY3Q9O6ooFxq50DayCdm0QrDgZjMUn23z/0PMZlgft7Yp5Q==" crossorigin="anonymous" />
    <style>
      body {
        background: #f4f4f5;
        color: #020202;
      }
      .navbar-dark {
        background-image: -webkit-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: -o-linear-gradient(top, #005f85 0, #002e49 100%);
        background-image: linear-gradient(to bottom, #005f85 0, #002e49 100%);
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff005f85', endColorstr='#ff002e49', GradientType=0);
        background-repeat: repeat-x;
      }
      .navbar-dark .navbar-nav .nav-link,
      .navbar-dark .navbar-nav .nav-link:focus { color: #fff }
      .navbar-dark .navbar-nav .nav-link:hover { color: #ffef68 }
      #wrapperlicious {
        margin: 0 auto;
        font: 0.9em 'Helvetica Neue', Helvetica, sans-serif;
        font-weight: normal;
        line-height: 1.5em;
        margin: 0;
        padding: 0;
      }
      #wrapperlicious h1 { font-size: 1.5em }
      #wrapperlicious h2 { font-size: 1.3em }
      #wrapperlicious h3 { font-size: 1.1em }
      #wrapperlicious h4 { font-size: 0.9em }
      #wrapperlicious h1, #wrapperlicious h2, #wrapperlicious h3,
      #wrapperlicious h4, #wrapperlicious dt {
        color: #020202;
        margin-top: 1em;
        margin-bottom: 1em;
        position: relative;
        font-weight: bold;
      }
      #wrapperlicious a { color: inherit; text-decoration: underline }
      #wrapperlicious #toc { text-decoration: none }
      #wrapperlicious a:hover { color: #2a2a2a }
      #wrapperlicious a img { border: 0 }
      #wrapperlicious :not(pre) > code {
        color: inherit;
        background-color: rgba(0, 0, 0, 0.04);
        border-radius: 3px;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        padding: 0.3em;
      }
      #wrapperlicious dd {
        margin: 0;
        margin-left: 2em;
      }
      #wrapperlicious dt {
        color: #2a2a2a;
        font-weight: bold;
        margin-left: 0.9em;
      }
      #wrapperlicious p {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious li > p {
        margin-bottom: 0;
        margin-top: 0;
      }
      #wrapperlicious pre {
        border: 1px solid #c1c1c1;
        border-radius: 3px;
        font: 100% Consolas, Menlo, Monaco, monospace;
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious pre > code {
        display: block;
        background-color: #f6f6f6;
        font: 0.9em Consolas, Menlo, Monaco, monospace;
        line-height: 1.5em;
        text-align: left;
        white-space: pre;
        padding: 1em;
      }
      #wrapperlicious dl, #wrapperlicious ol, #wrapperlicious ul {
        margin-bottom: 1em;
        margin-top: 1em;
      }
      #wrapperlicious ul {
        list-style-type: square;
      }
      #wrapperlicious ul ul {
        margin-bottom: 0px;
        margin-top: 0px;
      }
      #footer {
        font-size: 0.8em;
        padding-top: 0.5em;
        text-align: center;
      }
      #more {
        display: inline;
        font-size: 0.8em;
      }
      #perldocdiv {
        background-color: #fff;
        border: 1px solid #c1c1c1;
        border-bottom-left-radius: 5px;
        border-bottom-right-radius: 5px;
        margin-left: auto;
        margin-right: auto;
        padding: 3em;
        padding-top: 1em;
        max-width: 960px;
      }
      #moduleversion { float: right }
      #wrapperlicious .leading-notice {
        font-style: italic;
        padding-left: 1em;
        margin-top: 1em;
        margin-bottom: 1em;
      }
      #wrapperlicious .permalink {
        display: none;
        left: -0.75em;
        position: absolute;
        padding-right: 0.25em;
        text-decoration: none;
      }
      #wrapperlicious h1:hover .permalink, #wrapperlicious h2:hover .permalink,
      #wrapperlicious h3:hover .permalink, #wrapperlicious h4:hover .permalink,
      #wrapperlicious dt:hover .permalink {
        display: block;
      }
    </style>
    <!-- Global site tag (gtag.js) - Google Analytics -->
    <script async src="https://www.googletagmanager.com/gtag/js?id=G-KVNWBNT5FB"></script>
    <script>
      window.dataLayer = window.dataLayer || [];
      function gtag(){dataLayer.push(arguments);}
      gtag('js', new Date());

      gtag('config', 'G-KVNWBNT5FB');
      gtag('config', 'UA-50555-3');
    </script>
  </head>
  <body>
    <nav class="navbar navbar-expand-md navbar-dark bg-dark justify-content-between">
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
  <a class="navbar-brand" href="https://perldoc.perl.org/">Perldoc Browser</a>
  <div class="collapse navbar-collapse" id="navbarNav">
    <ul class="navbar-nav mr-auto">
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="mro.html#" id="dropdownlink-stable" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">5.35.0</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-stable">
          <a class="dropdown-item" href="https://perldoc.perl.org/mro">Latest</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.2/mro">5.38.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.1/mro">5.38.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0/mro">5.38.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.3/mro">5.36.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.2/mro">5.36.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.1/mro">5.36.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.36.0/mro">5.36.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.3/mro">5.34.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.2/mro">5.34.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.1/mro">5.34.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.34.0/mro">5.34.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.1/mro">5.32.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.32.0/mro">5.32.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.3/mro">5.30.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.2/mro">5.30.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.1/mro">5.30.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.30.0/mro">5.30.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.3/mro">5.28.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.2/mro">5.28.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.1/mro">5.28.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.28.0/mro">5.28.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.3/mro">5.26.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.2/mro">5.26.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.1/mro">5.26.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.26.0/mro">5.26.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.4/mro">5.24.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.3/mro">5.24.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.2/mro">5.24.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.1/mro">5.24.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.24.0/mro">5.24.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.4/mro">5.22.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.3/mro">5.22.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.2/mro">5.22.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.1/mro">5.22.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.22.0/mro">5.22.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.3/mro">5.20.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.2/mro">5.20.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.1/mro">5.20.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.20.0/mro">5.20.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.4/mro">5.18.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.3/mro">5.18.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.2/mro">5.18.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.1/mro">5.18.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.18.0/mro">5.18.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.3/mro">5.16.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.2/mro">5.16.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.1/mro">5.16.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.16.0/mro">5.16.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.4/mro">5.14.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.3/mro">5.14.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.2/mro">5.14.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.1/mro">5.14.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.14.0/mro">5.14.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.5/mro">5.12.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.4/mro">5.12.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.3/mro">5.12.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.2/mro">5.12.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.1/mro">5.12.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.12.0/mro">5.12.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.1/mro">5.10.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.10.0/mro">5.10.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.9/mro">5.8.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.8/mro">5.8.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.7/mro">5.8.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.6/mro">5.8.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.5/mro">5.8.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.4/mro">5.8.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.3/mro">5.8.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.2/mro">5.8.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.1/mro">5.8.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.8.0/mro">5.8.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.2/mro">5.6.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.1/mro">5.6.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.6.0/mro">5.6.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_04/mro">5.005_04</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_03/mro">5.005_03</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_02/mro">5.005_02</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005_01/mro">5.005_01</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.005/mro">5.005</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="mro.html#" id="dropdownlink-dev" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dev</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-dev">
          <a class="dropdown-item" href="https://perldoc.perl.org/blead/mro">blead</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.6/mro">5.39.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.5/mro">5.39.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.4/mro">5.39.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.3/mro">5.39.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.2/mro">5.39.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.39.1/mro">5.39.1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC2/mro">5.38.0-RC2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.38.0-RC1/mro">5.38.0-RC1</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.11/mro">5.37.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.10/mro">5.37.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.9/mro">5.37.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.8/mro">5.37.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.7/mro">5.37.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.6/mro">5.37.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.5/mro">5.37.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.4/mro">5.37.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.3/mro">5.37.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.2/mro">5.37.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.1/mro">5.37.1</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.37.0/mro">5.37.0</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.11/mro">5.35.11</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.10/mro">5.35.10</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.9/mro">5.35.9</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.8/mro">5.35.8</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.7/mro">5.35.7</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.6/mro">5.35.6</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.5/mro">5.35.5</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.4/mro">5.35.4</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.3/mro">5.35.3</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.2/mro">5.35.2</a>
          <a class="dropdown-item" href="https://perldoc.perl.org/5.35.1/mro">5.35.1</a>
          <a class="dropdown-item active" href="mro.html">5.35.0</a>
        </div>
      </li>
      <li class="nav-item dropdown text-nowrap">
        <a class="nav-link dropdown-toggle" href="mro.html#" id="dropdownlink-nav" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Documentation</a>
        <div class="dropdown-menu" aria-labelledby="dropdownlink-nav">
          <a class="dropdown-item" href="perl.html">Perl</a>
          <a class="dropdown-item" href="perlintro.html">Intro</a>
          <a class="dropdown-item" href="perl.html#Tutorials">Tutorials</a>
          <a class="dropdown-item" href="perlfaq.html">FAQs</a>
          <a class="dropdown-item" href="perl.html#Reference-Manual">Reference</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlop.html">Operators</a>
          <a class="dropdown-item" href="functions.html">Functions</a>
          <a class="dropdown-item" href="variables.html">Variables</a>
          <a class="dropdown-item" href="modules.html">Modules</a>
          <a class="dropdown-item" href="perlutil.html">Utilities</a>
          <div class="dropdown-divider"></div>
          <a class="dropdown-item" href="perlcommunity.html">Community</a>
          <a class="dropdown-item" href="perlhist.html">History</a>
        </div>
      </li>
    </ul>
    <ul class="navbar-nav">
      <script>
        function set_expand (expand) {
          var perldocdiv = document.getElementById('perldocdiv');
          var width = window.getComputedStyle(perldocdiv).getPropertyValue('max-width');
          var expanded = (width == '' || width == 'none') ? true : false;
          if (expand === null) {
            expand = !expanded;
          }
          if ((expand && !expanded) || (!expand && expanded)) {
            perldocdiv.style.setProperty('max-width', expand ? 'none' : '960px');
            var button_classlist = document.getElementById('content-expand-button').classList;
            if (expand) {
              button_classlist.add('btn-light');
              button_classlist.remove('btn-outline-light');
            } else {
              button_classlist.add('btn-outline-light');
              button_classlist.remove('btn-light');
            }
          }
          return expand;
        }
        function toggle_expand () {
          var expand = set_expand(null);
          document.cookie = 'perldoc_expand=' + (expand ? 1 : 0) + '; path=/; expires=Tue, 19 Jan 2038 03:14:07 UTC';
        }
        function read_expand () {
          return document.cookie.split(';').some(function (item) { return item.indexOf('perldoc_expand=1') >= 0 });
        }
        if (document.readyState === 'loading') {
          document.addEventListener('DOMContentLoaded', function () {
            if (read_expand()) {
              set_expand(true);
            }
          });
        } else if (read_expand()) {
          set_expand(true);
        }
      </script>
      <button id="content-expand-button" type="button" class="btn btn-outline-light d-none d-lg-inline-block mr-2" onclick="toggle_expand()">Expand</button>
    <ul>
    <form class="form-inline" method="get" action="https://perldoc.perl.org/5.35.0/search">
      <input class="form-control mr-3" type="search" name="q" placeholder="Search" aria-label="Search">
    </form>
  </div>
</nav>

    <div id="wrapperlicious" class="container-fluid">
      <div id="perldocdiv">
        <div id="links">
          <a href="mro.html">mro</a>
          <div id="more">
            (<a href="mro.txt">source</a>,
            <a href="https://metacpan.org/pod/mro">CPAN</a>)
          </div>
            <div id="moduleversion">version 1.25_001</div>
        </div>
        <div class="leading-notice">
          You are viewing the version of this documentation from Perl 5.35.0.
            This is a development version of Perl.
        </div>
        <h1><a id="toc">CONTENTS</a></h1>
                  <ul>
              <li>
                <a class="text-decoration-none" href="mro.html#NAME">NAME</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#SYNOPSIS">SYNOPSIS</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#DESCRIPTION">DESCRIPTION</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#OVERVIEW">OVERVIEW</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#The-C3-MRO">The C3 MRO</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="mro.html#What-is-C3?">What is C3?</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#How-does-C3-work">How does C3 work</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#Functions">Functions</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="mro.html#mro::get_linear_isa($classname%5B,-$type%5D)">mro::get_linear_isa($classname[, $type])</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#mro::set_mro-($classname,-$type)">mro::set_mro ($classname, $type)</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#mro::get_mro($classname)">mro::get_mro($classname)</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#mro::get_isarev($classname)">mro::get_isarev($classname)</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#mro::is_universal($classname)">mro::is_universal($classname)</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#mro::invalidate_all_method_caches()">mro::invalidate_all_method_caches()</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#mro::method_changed_in($classname)">mro::method_changed_in($classname)</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#mro::get_pkg_gen($classname)">mro::get_pkg_gen($classname)</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#next::method">next::method</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#next::can">next::can</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#maybe::next::method">maybe::next::method</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#SEE-ALSO">SEE ALSO</a>
                            <ul>
              <li>
                <a class="text-decoration-none" href="mro.html#The-original-Dylan-paper">The original Dylan paper</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#Python-2.3-MRO">Python 2.3 MRO</a>
              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#Class::C3">Class::C3</a>
              </li>
          </ul>

              </li>
              <li>
                <a class="text-decoration-none" href="mro.html#AUTHOR">AUTHOR</a>
              </li>
          </ul>

      <h1 id="NAME"><a class="permalink" href="mro.html#NAME">#</a>NAME</h1>

<p>mro - Method Resolution Order</p>

<h1 id="SYNOPSIS"><a class="permalink" href="mro.html#SYNOPSIS">#</a>SYNOPSIS</h1>

<pre><code>use mro; # enables next::method and friends globally

use mro &#39;dfs&#39;; # enable DFS MRO for this class (Perl default)
use mro &#39;c3&#39;; # enable C3 MRO for this class</code></pre>

<h1 id="DESCRIPTION"><a class="permalink" href="mro.html#DESCRIPTION">#</a>DESCRIPTION</h1>

<p>The &quot;mro&quot; namespace provides several utilities for dealing with method resolution order and method caching in general.</p>

<p>These interfaces are only available in Perl 5.9.5 and higher. See <a href="./MRO::Compat.html">MRO::Compat</a> on CPAN for a mostly forwards compatible implementation for older Perls.</p>

<h1 id="OVERVIEW"><a class="permalink" href="mro.html#OVERVIEW">#</a>OVERVIEW</h1>

<p>It&#39;s possible to change the MRO of a given class either by using <code>use mro</code> as shown in the synopsis, or by using the <a href="mro.html#mro%3A%3Aset_mro">&quot;mro::set_mro&quot;</a> function below.</p>

<p>The special methods <code>next::method</code>, <code>next::can</code>, and <code>maybe::next::method</code> are not available until this <code>mro</code> module has been loaded via <code>use</code> or <code>require</code>.</p>

<h1 id="The-C3-MRO"><a class="permalink" href="mro.html#The-C3-MRO">#</a><a id="The"></a>The C3 MRO</h1>

<p>In addition to the traditional Perl default MRO (depth first search, called <code>DFS</code> here), Perl now offers the C3 MRO as well. Perl&#39;s support for C3 is based on the work done in Stevan Little&#39;s module <a href="./Class::C3.html">Class::C3</a>, and most of the C3-related documentation here is ripped directly from there.</p>

<h2 id="What-is-C3?"><a class="permalink" href="mro.html#What-is-C3?">#</a><a id="What"></a><a id="What-is-C3"></a>What is C3?</h2>

<p>C3 is the name of an algorithm which aims to provide a sane method resolution order under multiple inheritance. It was first introduced in the language Dylan (see links in the <a href="mro.html#SEE-ALSO">&quot;SEE ALSO&quot;</a> section), and then later adopted as the preferred MRO (Method Resolution Order) for the new-style classes in Python 2.3. Most recently it has been adopted as the &quot;canonical&quot; MRO for Raku classes.</p>

<h2 id="How-does-C3-work"><a class="permalink" href="mro.html#How-does-C3-work">#</a><a id="How"></a>How does C3 work</h2>

<p>C3 works by always preserving local precedence ordering. This essentially means that no class will appear before any of its subclasses. Take, for instance, the classic diamond inheritance pattern:</p>

<pre><code class="plaintext">   &lt;A&gt;
  /   \
&lt;B&gt;   &lt;C&gt;
  \   /
   &lt;D&gt;</code></pre>

<p>The standard Perl 5 MRO would be (D, B, A, C). The result being that <b>A</b> appears before <b>C</b>, even though <b>C</b> is the subclass of <b>A</b>. The C3 MRO algorithm however, produces the following order: (D, B, C, A), which does not have this issue.</p>

<p>This example is fairly trivial; for more complex cases and a deeper explanation, see the links in the <a href="mro.html#SEE-ALSO">&quot;SEE ALSO&quot;</a> section.</p>

<h1 id="Functions"><a class="permalink" href="mro.html#Functions">#</a>Functions</h1>

<h2 id="mro::get_linear_isa($classname[,-$type])"><a class="permalink" href="mro.html#mro::get_linear_isa($classname%5B,-$type%5D)">#</a><a id="mro"></a><a id="mro::get_linear_isa-classname-type"></a>mro::get_linear_isa($classname[, $type])</h2>

<p>Returns an arrayref which is the linearized MRO of the given class. Uses whichever MRO is currently in effect for that class by default, or the given MRO (either <code>c3</code> or <code>dfs</code> if specified as <code>$type</code>).</p>

<p>The linearized MRO of a class is an ordered array of all of the classes one would search when resolving a method on that class, starting with the class itself.</p>

<p>If the requested class doesn&#39;t yet exist, this function will still succeed, and return <code>[ $classname ]</code></p>

<p>Note that <code>UNIVERSAL</code> (and any members of <code>UNIVERSAL</code>&#39;s MRO) are not part of the MRO of a class, even though all classes implicitly inherit methods from <code>UNIVERSAL</code> and its parents.</p>

<h2 id="mro::set_mro-($classname,-$type)"><a class="permalink" href="mro.html#mro::set_mro-($classname,-$type)">#</a><a id="mro1"></a><a id="mro::set_mro-classname-type"></a>mro::set_mro ($classname, $type)</h2>

<p>Sets the MRO of the given class to the <code>$type</code> argument (either <code>c3</code> or <code>dfs</code>).</p>

<h2 id="mro::get_mro($classname)"><a class="permalink" href="mro.html#mro::get_mro($classname)">#</a><a id="mro2"></a><a id="mro::get_mro-classname"></a>mro::get_mro($classname)</h2>

<p>Returns the MRO of the given class (either <code>c3</code> or <code>dfs</code>).</p>

<h2 id="mro::get_isarev($classname)"><a class="permalink" href="mro.html#mro::get_isarev($classname)">#</a><a id="mro3"></a><a id="mro::get_isarev-classname"></a>mro::get_isarev($classname)</h2>

<p>Gets the <code>mro_isarev</code> for this class, returned as an arrayref of class names. These are every class that &quot;isa&quot; the given class name, even if the isa relationship is indirect. This is used internally by the MRO code to keep track of method/MRO cache invalidations.</p>

<p>As with <code>mro::get_linear_isa</code> above, <code>UNIVERSAL</code> is special. <code>UNIVERSAL</code> (and parents&#39;) isarev lists do not include every class in existence, even though all classes are effectively descendants for method inheritance purposes.</p>

<h2 id="mro::is_universal($classname)"><a class="permalink" href="mro.html#mro::is_universal($classname)">#</a><a id="mro4"></a><a id="mro::is_universal-classname"></a>mro::is_universal($classname)</h2>

<p>Returns a boolean status indicating whether or not the given classname is either <code>UNIVERSAL</code> itself, or one of <code>UNIVERSAL</code>&#39;s parents by <code>@ISA</code> inheritance.</p>

<p>Any class for which this function returns true is &quot;universal&quot; in the sense that all classes potentially inherit methods from it.</p>

<h2 id="mro::invalidate_all_method_caches()"><a class="permalink" href="mro.html#mro::invalidate_all_method_caches()">#</a><a id="mro5"></a><a id="mro::invalidate_all_method_caches"></a>mro::invalidate_all_method_caches()</h2>

<p>Increments <code>PL_sub_generation</code>, which invalidates method caching in all packages.</p>

<h2 id="mro::method_changed_in($classname)"><a class="permalink" href="mro.html#mro::method_changed_in($classname)">#</a><a id="mro6"></a><a id="mro::method_changed_in-classname"></a>mro::method_changed_in($classname)</h2>

<p>Invalidates the method cache of any classes dependent on the given class. This is not normally necessary. The only known case where pure perl code can confuse the method cache is when you manually install a new constant subroutine by using a readonly scalar value, like the internals of <a href="constant.html">constant</a> do. If you find another case, please report it so we can either fix it or document the exception here.</p>

<h2 id="mro::get_pkg_gen($classname)"><a class="permalink" href="mro.html#mro::get_pkg_gen($classname)">#</a><a id="mro7"></a><a id="mro::get_pkg_gen-classname"></a>mro::get_pkg_gen($classname)</h2>

<p>Returns an integer which is incremented every time a real local method in the package <code>$classname</code> changes, or the local <code>@ISA</code> of <code>$classname</code> is modified.</p>

<p>This is intended for authors of modules which do lots of class introspection, as it allows them to very quickly check if anything important about the local properties of a given class have changed since the last time they looked. It does not increment on method/<code>@ISA</code> changes in superclasses.</p>

<p>It&#39;s still up to you to seek out the actual changes, and there might not actually be any. Perhaps all of the changes since you last checked cancelled each other out and left the package in the state it was in before.</p>

<p>This integer normally starts off at a value of <code>1</code> when a package stash is instantiated. Calling it on packages whose stashes do not exist at all will return <code>0</code>. If a package stash is completely deleted (not a normal occurrence, but it can happen if someone does something like <code>undef %PkgName::</code>), the number will be reset to either <code>0</code> or <code>1</code>, depending on how completely the package was wiped out.</p>

<h2 id="next::method"><a class="permalink" href="mro.html#next::method">#</a><a id="next"></a>next::method</h2>

<p>This is somewhat like <code>SUPER</code>, but it uses the C3 method resolution order to get better consistency in multiple inheritance situations. Note that while inheritance in general follows whichever MRO is in effect for the given class, <code>next::method</code> only uses the C3 MRO.</p>

<p>One generally uses it like so:</p>

<pre><code>sub some_method {
  my $self = shift;
  my $superclass_answer = $self-&gt;next::method(@_);
  return $superclass_answer + 1;
}</code></pre>

<p>Note that you don&#39;t (re-)specify the method name. It forces you to always use the same method name as the method you started in.</p>

<p>It can be called on an object or a class, of course.</p>

<p>The way it resolves which actual method to call is:</p>

<ol>

<li><p>First, it determines the linearized C3 MRO of the object or class it is being called on.</p>

</li>
<li><p>Then, it determines the class and method name of the context it was invoked from.</p>

</li>
<li><p>Finally, it searches down the C3 MRO list until it reaches the contextually enclosing class, then searches further down the MRO list for the next method with the same name as the contextually enclosing method.</p>

</li>
</ol>

<p>Failure to find a next method will result in an exception being thrown (see below for alternatives).</p>

<p>This is substantially different than the behavior of <code>SUPER</code> under complex multiple inheritance. (This becomes obvious when one realizes that the common superclasses in the C3 linearizations of a given class and one of its parents will not always be ordered the same for both.)</p>

<p><b>Caveat</b>: Calling <code>next::method</code> from methods defined outside the class:</p>

<p>There is an edge case when using <code>next::method</code> from within a subroutine which was created in a different module than the one it is called from. It sounds complicated, but it really isn&#39;t. Here is an example which will not work correctly:</p>

<pre><code>*Foo::foo = sub { (shift)-&gt;next::method(@_) };</code></pre>

<p>The problem exists because the anonymous subroutine being assigned to the <code>*Foo::foo</code> glob will show up in the call stack as being called <code>__ANON__</code> and not <code>foo</code> as you might expect. Since <code>next::method</code> uses <code>caller</code> to find the name of the method it was called in, it will fail in this case.</p>

<p>But fear not, there&#39;s a simple solution. The module <code>Sub::Name</code> will reach into the perl internals and assign a name to an anonymous subroutine for you. Simply do this:</p>

<pre><code>use Sub::Name &#39;subname&#39;;
*Foo::foo = subname &#39;Foo::foo&#39; =&gt; sub { (shift)-&gt;next::method(@_) };</code></pre>

<p>and things will Just Work.</p>

<h2 id="next::can"><a class="permalink" href="mro.html#next::can">#</a><a id="next1"></a>next::can</h2>

<p>This is similar to <code>next::method</code>, but just returns either a code reference or <code>undef</code> to indicate that no further methods of this name exist.</p>

<h2 id="maybe::next::method"><a class="permalink" href="mro.html#maybe::next::method">#</a><a id="maybe"></a>maybe::next::method</h2>

<p>In simple cases, it is equivalent to:</p>

<pre><code>$self-&gt;next::method(@_) if $self-&gt;next::can;</code></pre>

<p>But there are some cases where only this solution works (like <code>goto &amp;maybe::next::method</code>);</p>

<h1 id="SEE-ALSO"><a class="permalink" href="mro.html#SEE-ALSO">#</a><a id="SEE"></a>SEE ALSO</h1>

<h2 id="The-original-Dylan-paper"><a class="permalink" href="mro.html#The-original-Dylan-paper">#</a><a id="The1"></a>The original Dylan paper</h2>

<dl>

<dt id="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.19.3910&amp;rep=rep1&amp;type=pdf"><a class="permalink" href="mro.html#http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.19.3910&amp;rep=rep1&amp;type=pdf">#</a><a id="http"></a><a id="http:-citeseerx.ist.psu.edu-viewdoc-download-doi-10.1.1.19.3910rep-rep1type-pdf"></a><a href="http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.19.3910&amp;rep=rep1&amp;type=pdf">http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.19.3910&amp;rep=rep1&amp;type=pdf</a></dt>
<dd>

</dd>
</dl>

<h2 id="Python-2.3-MRO"><a class="permalink" href="mro.html#Python-2.3-MRO">#</a><a id="Python"></a>Python 2.3 MRO</h2>

<dl>

<dt id="https://www.python.org/download/releases/2.3/mro/"><a class="permalink" href="mro.html#https://www.python.org/download/releases/2.3/mro/">#</a><a id="https"></a><a id="https:-www.python.org-download-releases-2.3-mro"></a><a href="https://www.python.org/download/releases/2.3/mro/">https://www.python.org/download/releases/2.3/mro/</a></dt>
<dd>

</dd>
</dl>

<h2 id="Class::C3"><a class="permalink" href="mro.html#Class::C3">#</a><a id="Class"></a>Class::C3</h2>

<dl>

<dt id="Class::C31"><a class="permalink" href="mro.html#Class::C31">#</a><a id="Class1"></a><a href="./Class::C3.html">Class::C3</a></dt>
<dd>

</dd>
</dl>

<h1 id="AUTHOR"><a class="permalink" href="mro.html#AUTHOR">#</a>AUTHOR</h1>

<p>Brandon L. Black, &lt;blblack@gmail.com&gt;</p>

<p>Based on Stevan Little&#39;s <a href="./Class::C3.html">Class::C3</a></p>


      </div>
      <div id="footer">
        <p>Perldoc Browser is maintained by Dan Book (<a href="https://metacpan.org/author/DBOOK">DBOOK</a>). Please contact him via the <a href="https://github.com/Grinnz/perldoc-browser/issues">GitHub issue tracker</a> or <a href="mailto:dbook@cpan.org">email</a> regarding any issues with the site itself, search, or rendering of documentation.</p>

<p>The Perl documentation is maintained by the Perl 5 Porters in the development of Perl. Please contact them via the <a href="https://github.com/Perl/perl5/issues">Perl issue tracker</a>, the <a href="https://lists.perl.org/list/perl5-porters.html">mailing list</a>, or <a href="https://kiwiirc.com/client/irc.perl.org/p5p">IRC</a> to report any issues with the contents or format of the documentation.</p>


      </div>
    </div>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.slim.min.js" integrity="sha512-/DXTXr6nQodMUiq+IUJYCt2PPOUjrHJ9wFrqpJ3XkgPNOZVfMok7cRw6CSxyCQxXn6ozlESsSh1/sMCTF1rL/g==" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.1/umd/popper.min.js" integrity="sha512-ubuT8Z88WxezgSqf3RLuNi5lmjstiJcyezx34yIU2gAHonIi27Na7atqzUZCOoY4CExaoFumzOsFQ2Ch+I/HCw==" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script>
    <script src="../highlight.pack.js"></script>
    <script>hljs.highlightAll();</script>
  </body>
</html>
